/*
通过axios建立的服务，调用get/post的请求方法
*/

import request from '@/utils/request'

//登录接口
export const pwdLogin = (info) => {
    return request.post("user/pwdLogin", info)
}

//phone是字符串类型
export const codeLogin = (info) => {
    return request.get("user/codeLogin", {params: {phone: info}})
}


//用户信息接口
export const getUserInfo = () => {
    return request.get("user/getUserInfo")
}

//发送验证码
export const sendCode = (phone) => {
    return request.get("user/sendCode", {params: {phone: phone}})
}

//查询动态列表
export const getDynamicList = (info) => {
    return request.get("dynamic/list",{params: info})
}

//关注
export const followUser= (info) => {
    return request({
        url: '/follows/user',
        method: 'post',
        params: {targetId:info}
    })
}

//点赞动态
export const likeDynamic = (dynamicId) => {
    return request({
        url: '/like/dynamic',
        method: 'post',
        params: {dynamicId: dynamicId}
    });
}

//点赞评论
export const likeComment = (commentId) => {
    return request({
        url: '/like/comment',
        method: 'post',
        params: {commentId: commentId}
    });
};

//收藏动态
export const favoriteDynamic = (dynamicId) => {
    return request({
        url: '/favorite/dynamic',
        method: 'post',
        params: {dynamicId: dynamicId}
    });
}

//关注圈子
export const followGroup = (groupId) => {
    return request({
        url: '/follows/group',
        method: 'post',
        params: {groupId: groupId}
    });
};

//获取圈子详情
export const getGroupDetail = (groupId) => {
    return request.get(`/group/getInfo/${groupId}`);
};

//搜索圈子
export const searchGroups = (keyword) => {
    return request.get(`/group/search`, {params: {keyword: keyword}});
};

//获取评论列表
export const getCommentList = (info) => {
    return request.get("/comment/list",{params: info});
};

//发布评论
export const publishComment = (info) => {
    return request.post("/comment/publish",info);
};
